﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using CacheHelper = FJASPX.Framwork.Helper.CacheHelper;
namespace FJASPX.Framwork.Config
{
    public class ConfigBase
    {
        public static string GetConfig(string key)
        {
            return GetConfig(key, true);
        }
        private const string configCacheEx = "config_";
        public static string GetConfig(string key, bool isCached)
        {
            if (!isCached)
            {
                return ConfigurationManager.AppSettings[key];
            }

            if (CacheHelper.IsNull(configCacheEx + key))
            {
                CacheHelper.SetCache(
                    (configCacheEx + key),
                    ConfigurationManager.AppSettings[key],
                    120d);//缓存120分钟
            }
            return (string)CacheHelper.GetCache(configCacheEx + key);
        }
    }
}